import { getClassifyList } from "../utils/api.js"

const classifyList = {
    namespaced: true,//命名空间
    state: {//定义全局的状态
        classifyList: [],
        type: '1',//导航栏的id，为了Side和RightList里面的同步，在此处定义全局的sld
    },
    mutations: {
        //mutations是唯一能改变state的地方
        changeClassifyList(state, payload) {
            state.classifyList = payload.list
        },
        changetype(state, payload) {
            state.type = payload;
        }

    },
    actions: {
        //获取分类页接口数据
        async getClassifyList({ commit }, payload) {
            const result = await getClassifyList(payload)
            commit('changeClassifyList', {
                list: result.result
            })

        }
    },
}
export default classifyList